﻿
using System.Windows;
using System.Windows.Controls;

namespace SharpSoft.WPF.Masks
{
    public class ToastTemplate : Control
    {

        static ToastTemplate()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ToastTemplate), new FrameworkPropertyMetadata(typeof(ToastTemplate)));
        }
        public ToastTemplate()
        {
            this.DataContext = this;
            this.Style = (Style)FindResource(new ComponentResourceKey(typeof(ToastTemplate), "toast_info"));
        }

        public const string IconError = "";

        public const string IconInfo = "";

        public const string IconNotice = "";

        public const string IconSuccess = "";

        public const string IconWarning = "";


        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(ToastTemplate), new PropertyMetadata(null));



        public string Message
        {
            get { return (string)GetValue(MessageProperty); }
            set { SetValue(MessageProperty, value); }
        }

        public static readonly DependencyProperty MessageProperty =
            DependencyProperty.Register("Message", typeof(string), typeof(ToastTemplate), new PropertyMetadata(""));



        public string Icon
        {
            get { return (string)GetValue(IconProperty); }
            set { SetValue(IconProperty, value); }
        }
        public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register("Icon", typeof(string), typeof(ToastTemplate), new PropertyMetadata(null));



        public ToastType Type
        {
            get { return (ToastType)GetValue(TypeProperty); }
            set { SetValue(TypeProperty, value); }
        }

        public static readonly DependencyProperty TypeProperty =
            DependencyProperty.Register("Type", typeof(ToastType), typeof(ToastTemplate), new PropertyMetadata(ToastType.Info));

        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (e.Property == TypeProperty)
            {
                switch (this.Type)
                {
                    case ToastType.Success:
                        this.Style = (Style)FindResource(new ComponentResourceKey(typeof(ToastTemplate), "toast_success"));
                        break;
                    case ToastType.Error:
                        this.Style = (Style)FindResource(new ComponentResourceKey(typeof(ToastTemplate), "toast_error"));
                        break;
                    case ToastType.Waring:
                        this.Style = (Style)FindResource(new ComponentResourceKey(typeof(ToastTemplate), "toast_warning"));
                        break;
                    case ToastType.Info:
                        this.Style = (Style)FindResource(new ComponentResourceKey(typeof(ToastTemplate), "toast_info"));
                        break;
                    default:
                        break;
                }
            }
        }
        public enum ToastType
        {
            Success,
            Error,
            Waring,
            Info
        }
    }
}
